// Purpose : This Page showing rating of a doctor givin by patient.
// Date    : 26 Sep, 2007
// Author  : Vinayak Singh Rathore
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SiteManager;
public partial class DashBoard_MyPatient : System.Web.UI.Page
{
    protected  int iDoctorid; // Assign Doctor id form session variable
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            // CODE COMMENTED AS DENTIST WERE NOT ABLE TO ACCESS THIS PAGE
            // DATE 18TH FEB 2008

            //localFunction drchk = new localFunction();
            //drchk.checkDoctorLogin(true);

            localFunction lfunction = new localFunction();
            if (Session["DoctorType"].ToString() == "Doctor")
                lfunction.checkDoctorLogin(true);
            else if (Session["DoctorType"].ToString() == "Dentist")
                lfunction.checkDentistLogin(true);
            else
                Response.Redirect(Session["strHttp"].ToString());

            // COMMENT ENDS

            if (Session["userID"].ToString() != "" && Session["userID"] != null)
            {
                // find Doctor id from session
               iDoctorid = Convert.ToInt32(Session["userID"]);

            }
            // Bind repeater control
            BindReapeter();
        }

    }
    /// <summary>
    /// public void BindReapeter()
    /// </summary>
    public void BindReapeter()
    {
        int userType=0;
        // check user type, this is dentist or doctor
        Manager objManager = new Manager(true,"ConnectionString");
        DataSet ds = new DataSet();
        if ((Session["userType"].ToString() == "Doctor") && ((Convert.ToString(Session["DoctorType"]).Length == 0)))
            userType = 2;
        else if ((Session["userType"].ToString() == "Doctor") && (Convert.ToString(Session["DoctorType"]) == "Dentist"))
            userType = 4;
        //if user type is 2 then get record from my doctor
        if (userType == 2)
        {
            ds = objManager.ExecuteQuery("select  (fname+' '+Mname+' '+Lname)as [Name] from tbl_users where id in(select userid from mydoctors where doctorid=" + iDoctorid + ")", "myPatient");
            if (ds.Tables[0].Rows.Count > 0)
            {
                rpMyPatient.DataSource = ds;
                rpMyPatient.DataBind();
            }
            else
            {
                rpMyPatient.DataSource = ds;
                rpMyPatient.DataBind();
                lblMsg.Text = "No Record Exist.";
            }

        }
            // else from my dentist
        else
        {
          //  Response.Write("select  (fname+' '+Mname+' '+Lname)as [Name] from tbl_users where id in(select userid from mydentist where dentistid=" + iDoctorid + ")");
            ds = objManager.ExecuteQuery("select  (fname+' '+Mname+' '+Lname)as [Name] from tbl_users where id in(select userid from mydentist where dentistid=" + iDoctorid + ")", "myPatient");
            if (ds.Tables[0].Rows.Count > 0)
            {
                rpMyPatient.DataSource = ds;
                rpMyPatient.DataBind();
            }
            else
            {
                lblMsg.Text = "No Record Exist.";
                rpMyPatient.DataSource = ds;
                rpMyPatient.DataBind();
            }

        }
    }
}
